home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / AB3DIIsrc / source_4000 / CALCBIGPAL.s < prev    next >
Encoding:
Text File  |  1996-10-08  |  1.6 KB  |  140 lines

  1. VALS:
  2.  dc.l 0
  3.  dc.l 0
  4.  
  5. Start:
  6.  
  7.  
  8.  lea VALS(pc),a0
  9.  move.l (a0)+,a1    ; dest buffer
  10.  move.l (a0)+,a2    ; palette data
  11.  
  12.  move.w #32,d6
  13. BRIGHTLOOP
  14.  
  15.  move.w #31,d7        ; specular counter
  16.  move.w #0,d4        ; specular amount
  17. SPECLOOP
  18.  
  19.  move.w #31,d4
  20.  sub.w d7,d4
  21.  move.w d4,d1
  22.  muls d4,d4
  23.  muls d1,d4
  24.  asr.l #5,d4
  25.  
  26.  swap d7
  27.  
  28.  move.w #255,d5        ; colour counter
  29.  move.l a2,a0        ; colour pointer
  30. COLOURLOOP:
  31.  moveq #0,d0
  32.  moveq #0,d1
  33.  moveq #0,d2
  34.  
  35.  
  36.  move.w (a0)+,d0    ; r
  37.  move.w (a0)+,d1    ; g
  38.  move.w (a0)+,d2    ; b
  39.  
  40.  cmp.w #8,d5
  41.  ble.s .nodark
  42.  
  43.  add.w #10,d6
  44.  muls d6,d0
  45.  divs #42,d0
  46.  
  47.  muls d6,d1
  48.  divs #42,d1
  49.  
  50.  muls d6,d2
  51.  divs #42,d2
  52.  sub.w #10,d6
  53. .nodark:
  54.  
  55.  move.w d0,a4        ; r
  56.  move.w d1,a5        ; g
  57.  move.w d2,a6        ; b
  58.  
  59.  neg.w d0
  60.  neg.w d1
  61.  neg.w d2
  62.  add.w #255,d0
  63.  add.w #255,d1
  64.  add.w #255,d2
  65.  
  66.  muls d4,d0
  67.  divs #24*32,d0
  68.  muls d4,d1
  69.  divs #24*32,d1
  70.  muls d4,d2
  71.  divs #24*32,d2
  72.  
  73.  add.w a4,d0
  74.  add.w a5,d1
  75.  add.w a6,d2
  76.  
  77.  cmp.w #255,d0
  78.  blt .okred
  79.  move.w #255,d0
  80. .okred
  81.  cmp.w #255,d1
  82.  blt .okgreen
  83.  move.w #255,d1
  84. .okgreen
  85.  cmp.w #255,d2
  86.  blt .okblue
  87.  move.w #255,d2
  88. .okblue
  89.  
  90.  nop
  91.  nop
  92.  
  93.  move.w d0,a4        ; r
  94.  move.w d1,a5        ; g
  95.  move.w d2,a6        ; b
  96.  
  97.  move.l #1000000,d3
  98.  move.w #255,d0
  99.  move.l a2,a3
  100. findclose:
  101.  
  102.  move.w (a3)+,d1    ; r
  103.  sub.w a4,d1
  104.  muls.w d1,d1
  105. ; muls.w d1,d1
  106.  move.w (a3)+,d2    ; g
  107.  sub.w a5,d2
  108.  muls.w d2,d2
  109. ; muls.w d2,d2
  110.  add.l d2,d1
  111.  move.w (a3)+,d2    ; b
  112.  sub.w a6,d2
  113.  muls.w d2,d2
  114. ; muls.w d2,d2
  115.  add.l d2,d1
  116.  
  117.  cmp.l d1,d3
  118.  ble.s .notcloser
  119.  
  120.  move.l d1,d3
  121.  move.w d0,d7
  122.  
  123. .notcloser:
  124.  dbra d0,findclose
  125.  
  126.  neg.w d7
  127.  add.w #255,d7
  128.  move.b d7,(a1)+
  129.  
  130.  dbra d5,COLOURLOOP
  131.  
  132.  add.w #8,d4
  133.  swap d7
  134.  dbra d7,SPECLOOP
  135.  
  136.  subq #1,d6
  137.  bgt BRIGHTLOOP
  138.  
  139.  rts
  140.